Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click this button to invoke an onclick event, and check whether it is trusted:</p> <button id="myBtn" onclick="myFunction(event)">Try it</button> <p>Click this button to trigger an onclick event by a script, and check whether it is trusted:</p> <button onclick="triggerClick()">Try it</button> <p><strong>Note:</strong> The isTrusted property is currently only supported in Firefox and Internet Explorer.</p> <script> function myFunction(event) { if ("isTrusted" in event) { if (event.isTrusted) { alert ("The " + event.type + " event is trusted."); } else { alert ("The " + event.type + " event is not trusted."); } } else { alert ("The isTrusted property is not supported by your browser"); } } function triggerClick() { var btn = document.getElementById("myBtn"); btn.click(); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_event_istrusted by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:30:34 GMT --> </html>
Result:
Try it Yourself - © w3schools.com